<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2023/5/13
 * Time: 15:56
 */

namespace app\index\model;


use think\Model;

class CrmCustomerManage extends Model
{
    public function items(){
        return $this->hasMany('CrmDurations','phone','phone')->field('id,phone,duration,status');
    }

    public function durations($wheres,$where){
        return $this->where($wheres)->where($where)->group('client_id')->field('phone')->withCount(['items'=>function($query) use($where){
            $query->where($where);
        }])->select();
    }
}